<template>
	<view>
		<topbar :title="title" jt_c="2" background="background:#222222;color:#fff;"></topbar>
		<view class="content">
			<view style="margin-bottom: 24rpx;">{{text}}</view>
			<view class="dis_f_co" style="width: 100%;">
				<u-radio-group v-model="value" @change="radioGroupChange">
				<view class="tx_btn" style="margin-bottom: 12rpx;" @click="change(1)" v-if="wx_show">
					<view class="dis_f_sb_c" style="width: 100%;">
						<view class="dis_f_l_c">
							<image class="logo" src="../../static/mine/vx.png" mode=""></image>
							<view>{{text1}}</view>
						</view>
						<u-radio name="1"></u-radio>
					</view>
				</view>
				<view class="tx_btn">
					<view class="dis_f_sb_c" style="width: 100%;" @click="change(2)">
						<view class="dis_f_l_c">
							<image class="logo" src="../../static/mine/zfb.png" mode=""></image>
							<view>{{text2}}</view>
						</view>
						<u-radio name="2"></u-radio>
					</view>
				</view>
				</u-radio-group>
			</view>
		</view>
		<view class="next dis_f_c_c" @click="go_next">确定</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value: '',
				type:'',
				title:'',
				text:'',
				text1:'',
				text2:'',
				cz:'',
				user:[],
				wx_show:true,
			};
		},
		onLoad(opt) {
			if(uni.getSystemInfoSync().platform == 'ios'){
				this.wx_show = false
			}
			this.cz = opt.cz
			if(opt.cz == 1){
				this.title = '充值'
				this.text = '请选择支付方式'
				this.text1 = '微信支付'
				this.text2 = '支付宝支付'
			}else{
				this.title = '提现'
				this.text = '请选择提现账户'
				this.text1 = '提现到微信'
				this.text2 = '提现到支付宝'
			}
			this.$.ajax(1, 'post', 'index/getuser', {
				uid:uni.getStorageSync('uid'),
				token:uni.getStorageSync('token')
			}, (res) => {
				console.log(res)
				if(res.code == 1){
					this.user = res.userinfo
				}
			})
		},
		onShow() {
			this.$.ajax(1, 'post', 'index/getuser', {
				uid:uni.getStorageSync('uid'),
				token:uni.getStorageSync('token')
			}, (res) => {
				console.log(res)
				if(res.code == 1){
					this.user = res.userinfo
				}
			})
		},
		methods:{
			change(e){
				this.type = e
				this.value = e
			},
			radioGroupChange(e) {
				this.type = e
				console.log(this.type)
			},
			go_next(){
					this.$.ajax(1, 'post', 'index/checktokens', {
						uid:uni.getStorageSync('uid'),
						token:uni.getStorageSync('token')
					}, (res) => {
						console.log(res)
						if(res.code == 9){
							this.$.ti_shi('token已过期，请重新登陆')
						uni.clearStorageSync()
							setTimeout( () => {
								uni.navigateTo({
									url:'/pages/login/login'
								})
							}, 1000)
						return;
						}
						else{
							console.log(this.type)
							if(this.type != ''){
								if(this.cz == 1){
									this.$.open('/pages/mine/tx2?type='+this.type + '&cz=' + 1)
									
									
								}else{
									if(this.user.wechat != '' && this.type == 1){
										this.$.open('/pages/mine/tx2?type='+this.type)
									}else if(this.user.wechat == '' && this.type == 1){
										this.$.ti_shi('请去设置微信收款码')
											setTimeout( () => {
										uni.navigateTo({
												url:'/pages/mine/she_zhi'
											})
										}, 1000)
									}else if(this.user.alipay != '' && this.type == 2){
											this.$.open('/pages/mine/tx2?type='+this.type)
									}else if(this.user.alipay == '' && this.type == 2){
										this.$.ti_shi('请去设置支付宝收款账号')
											setTimeout( () => {
										uni.navigateTo({
												url:'/pages/mine/she_zhi'
											})
										}, 1000)
									}
									
								}
							}else{
								this.$.ti_shi('请选择提现账户')
							}
						}
					})
				
			}
		}
	}
</script>

<style lang="scss">
	.content{
		padding: calc(var(--status-bar-height) + 124rpx) 24rpx 0 24rpx;
		width: 100%;
		.tx_btn{
			width: 100%;
			height: 120rpx;
			background-color: #fff;
			border-radius: 20rpx;
			box-shadow: 0rpx 6rpx 24rpx rgba(34, 34, 34, 0.05);
			padding: 30rpx 24rpx;
		}
		.logo{
			width: 60.04rpx;
			height: 60.04rpx;
			margin-right: 18rpx;
		}
		
	}
	.next{
		position: fixed;
		bottom: 84rpx;
		left: 24rpx;
		width: 702rpx;
		height: 98rpx;
		border-radius: 50rpx;
		background-color: #E23C63;
		color: #fff;
	}
</style>
